package org.sgx.gwteditors.testgallery.gallery;

import java.util.Map;

import org.sgx.gwteditors.client.editor.event.EditorValueChangeEvent;
import org.sgx.gwteditors.client.editor.event.ValueChangeListener;
import org.sgx.gwteditors.client.impl1.basetypes.Color;
import org.sgx.gwteditors.client.impl1.basetypes.InRangeDouble;
import org.sgx.gwteditors.client.impl1.basetypes.InRangeInteger;
import org.sgx.gwteditors.client.impl1.simple.ColorEditor;
import org.sgx.gwteditors.client.impl1.simple.InRangeDoubleEditor;
import org.sgx.gwteditors.client.impl1.simple.InRangeIntegerEditor;
import org.sgx.gwteditors.client.impl1.ui.slider.HSliderWidget1;
import org.sgx.gwteditors.client.util.TestUtil;

import com.google.gwt.resources.client.ExternalTextResource;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Panel;

public class InRangeTest1 implements Test {	
	
	@Override
	public void test(Panel parent) {		
		InRangeInteger r1 = new InRangeInteger(100, 200, 150); 
		InRangeIntegerEditor ed = new InRangeIntegerEditor(); 
		ed.load(r1); 
		ed.addValueChangeListener(new ValueChangeListener<InRangeInteger>() {			
			@Override
			public void notifyValueChange(EditorValueChangeEvent<InRangeInteger> evt) {
				Window.alert(evt.getValue()+""); 
			}
		}); 
		parent.add(ed.getWidget());
		
		InRangeDouble r2 = new InRangeDouble(0.0, 1.0, 0.4); 
		InRangeDoubleEditor ed2 = new InRangeDoubleEditor(); 
		ed2.load(r2); 
		ed2.addValueChangeListener(new ValueChangeListener<InRangeDouble>() {			
			@Override
			public void notifyValueChange(EditorValueChangeEvent<InRangeDouble> evt) {
				Window.alert(evt.getValue()+""); 
			}
		}); 
		parent.add(ed2.getWidget());
	}

	
	//test stuff
	@Override
	public String getName() {
		return "inrangeinteger 1";
	}

	@Override
	public String[] getTags() {		
		return null;
	}

	@Override
	public String getDescription() {
		return "show how to use inrange integer editor";
	}

//	@Override
//	public String[] getJavaSources() {
//		return new String[]{TestResources.INSTANCE.InRangeTest1().getText()};
//	}
	@Override
	public Map<String, ExternalTextResource> getJavaSources() {
		return TestUtil.getResource(getName(), TestResources.INSTANCE.InRangeTest1());
	}
}
